//
//  GMHSecondViewController.m
//  
//
//  Created by 郭明皓 on 15/10/22.
//
//

#import "GMHSecondViewController.h"
#import "HUDManager.h"
#import "UMSocial.h"
@interface GMHSecondViewController ()<UIWebViewDelegate>

@end

@implementation GMHSecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    [HUDManager showStatus];
//    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"goback.png"] style:UIBarButtonItemStyleDone target:self action:@selector(back)];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 40, 40);
    [button setImage:[UIImage imageNamed:@"share.png"] forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]initWithCustomView:button]autorelease];
    [button addTarget:self action:@selector(share:) forControlEvents:UIControlEventTouchUpInside];

    
    self.title = self.titles;
    
    UIWebView *web = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height + 49)];
    [self.view addSubview:web];
    web.scrollView.scrollEnabled = NO;
    [web release];
    web.delegate = self;
    web.scalesPageToFit = YES;
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.url]];
    [web loadRequest:request];
    
}
//webView开始加载
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [HUDManager dismissHUD];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [HUDManager dismissHUD];
}

//- (void)back
//{
//    [HUDManager dismissHUD];
//    [self.navigationController popToRootViewControllerAnimated:YES];
//}
//- (void)webViewDidStartLoad:(UIWebView *)webView
//{
//     [HUDManager dismissHUD];
//}

#pragma mark 分享信息
- (void)share:(UIButton *)sharebutton
{
    NSLog(@"分享成功");
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"5639a9fd67e58e5fad00119c"
                                      shareText:self.url
                                     shareImage:nil
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToWechatSession,UMShareToQQ, UMShareToEmail, UMShareToSms, UMShareToQzone, UMShareToWechatTimeline, UMShareToTencent,nil]
                                       delegate:nil];
}

//- (void)viewWillAppear:(BOOL)animated
//{
//    UIImageView *backImage = [[UIImageView alloc]initWithFrame:self.view.frame];
//    [self.view addSubview:backImage];
//    [backImage release];
//    backImage.image = [UIImage imageNamed:@"travel.jpg"];
//    //毛玻璃效果
//    UIBlurEffect *logineffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
//    UIVisualEffectView *logineffectView = [[UIVisualEffectView alloc]initWithEffect:logineffect];
//    logineffectView.frame = CGRectMake(0, 0, backImage.frame.size.width, backImage.frame.size.height);
//    [backImage addSubview:logineffectView];
//    logineffectView.alpha = 1;
//
//    [HUDManager showStatus];
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
